var express = require('express');
var user = require('./user.js');
var room = require('./room.js');
var message = require('./message.js');

var callbacks = [];
var app = express.createServer();
app.get('/join_user', function(req, res){
    var uid = req.params.uid;
    var nick = req.params.nick;
    user.join(uid, nick);
});
app.get('/join_room', function(req, res){
    var uid = req.params.uid;
    var room_id = req.params.room_id;
    room.join(uid, room_id);
});


for(var i=0; i<callbacks.length; i++){
        var callback = callbacks[i];
        if(callback.to_uid == to_uid || to_uid == 0 || callback.to_uid == from_uid){
            callback.callback(m);
            //delete callbacks[i];
            //console.log('append ['+type+'] ,to_uid: '+callback.to_uid+'\n');
        }
    }


/*
var p = process.memoryUsage();
console.log(p.rss/1000000);
*/